import java.awt.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;

public class demo1 {
    public static void main(String[] args) {
        int[] nums={3,1,4,1,5,9};

        System.out.println(Arrays.toString( two(nums,9)));

    }
    public  static int[] two(int[] nums, int target) {
        Map<Integer,Integer> map=new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            if(!map.containsKey(target-nums[i])) {
                map.put(nums[i],i);
            }else{
                return new int[]{map.get(target-nums[i]),i};
            }

        }
        return new int[]{};

    }
}
